<template>
  <div class="app-container">
    <el-card class="box-card">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" >

      <el-form-item label="姓名" prop="username">
        <el-input
          v-model="queryParams.username"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="部门" prop="deptid">
        <el-select v-model="queryParams.deptid" placeholder="请选择部门" style="width:90%;float:left">
          <el-option
            v-for="dict in dict.type.yh_deptid"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <!--
            <el-form-item label="证件编号" prop="certificateId">
              <el-input
                v-model="queryParams.certificateId"
                placeholder="请输入证件编号"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
      -->

      <el-form-item label="政治面貌" prop="politics" >
        <el-select v-model="queryParams.politics" clearable placeholder="请选择政治面貌">
          <el-option
            v-for="dict in dict.type.yh_politics"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所在支部" prop="branch" v-show="showSearch">
        <el-input
          v-model="queryParams.branch"
          placeholder="请输入所在支部"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="介绍信编号" prop="note1" v-show="showSearch">
        <el-input
          v-model="queryParams.note1"
          placeholder="请输入介绍信编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <div style="text-align: right;margin-right:-9px;">
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </div>

    </el-form>

    <el-row :gutter="10" class="mb8">
<!--      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['dr:transfer:add']"
        >新增
        </el-button>
      </el-col>-->


      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['dr:transfer:remove']"
        >删除
        </el-button>
      </el-col>


<!--      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['dr:transfer:import']"
        >导入
        </el-button>
      </el-col>-->


      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['dr:transfer:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="transferList" border @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        v-if="columns[0].visible"
        label="序号"
        type="index"
        width="50"
        align="center">
        <template scope="scope">
          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="姓名" align="center" prop="username" v-if="columns[0].visible"/>
      <el-table-column label="性别" align="center" prop="gender" v-if="columns[1].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.gender"/>
        </template>
      </el-table-column>
      <el-table-column label="年龄" align="center" prop="age" v-if="columns[2].visible"/>
      <el-table-column label="部门" align="center" prop="deptid" v-if="columns[3].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_deptid" :value="scope.row.deptid"/>
        </template>
      </el-table-column>
      <el-table-column label="身份证号" align="center" prop="idNumber" v-if="columns[4].visible"/>
      <el-table-column label="籍贯" align="center" prop="nativePlace" v-if="columns[5].visible"/>
      <el-table-column label="民族" align="center" prop="nation" v-if="columns[6].visible"/>
      <el-table-column label="政治面貌" align="center" prop="politics" v-if="columns[7].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_politics" :value="scope.row.politics"/>
        </template>
      </el-table-column>
      <el-table-column label="所在支部" align="center" prop="branch" v-if="columns[8].visible"/>
      <el-table-column label="家庭住址" align="center" prop="homeAddress" v-if="columns[9].visible"/>
      <el-table-column label="介绍信编号" align="center" prop="note1" v-if="columns[10].visible"/>
      <el-table-column label="上级党组织名称" align="center" prop="note2" v-if="columns[11].visible"/>
      <el-table-column label="入党/团时间" align="center" prop="partyTime" width="180"v-if="columns[12].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.partyTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="组织关系接收单位名称" align="center" prop="organizationRelationship" v-if="columns[13].visible"/>
      <el-table-column label="组织关系接收单位所在城市" align="center" prop="organizationCity" v-if="columns[14].visible"/>
      <el-table-column label="备注" align="center" prop="remark" v-if="columns[15].visible"/>
      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['dr:transfer:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleDelete(scope.row)"
            v-hasPermi="['dr:transfer:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleView(scope.row,scope.index)"
            v-hasPermi="['dr:transfer:query']"
          >详细</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>
    <!--导入 -->
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的基本信息数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="danger" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改关系转接对话框 -->
    <el-dialog :title="title" :visible.sync="open" append-to-body width="1300px">
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">个人基本信息</p>
            </el-divider>
          </el-header>

          <el-main>
            <!--第一行-->
            <el-row>
              <el-col :span="8">
                <el-form-item label="姓名" prop="username">
                  <el-autocomplete
                    readonly =“readonly”
                    style="width:90%;float:left"
                    placeholder="请输入姓名"
                    v-model="form.username"
                    :fetch-suggestions="querySearchAsync"
                    @select="handleSelect"
                  >
                  </el-autocomplete>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="性别" prop="gender">
                  <el-select v-model="form.gender" disabled="disabled" placeholder="请选择性别" style="width:90%;float:left">
                    <el-option
                      v-for="dict in dict.type.sys_user_sex"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="年龄" prop="age">
                  <el-input readonly =“readonly” v-model="form.age" placeholder="请输入年龄" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="部门"  prop="deptid">
                  <el-select disabled="disabled" v-model="form.deptid" placeholder="请选择部门" style="width:90%;float:left">
                    <el-option
                      v-for="dict in dict.type.yh_deptid"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="籍贯"  prop="nativePlace">
                  <el-input readonly =“readonly” v-model="form.nativePlace" placeholder="请输入籍贯" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="民族"  prop="nation">
                  <!--                  <el-input v-model="form.nation" placeholder="请输入民族"/>-->
                  <el-select disabled="disabled" v-model="form.nation" filterable placeholder="请输入民族" style="width:90%;float:left">
                    <el-option
                      v-for="item in option_nation"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="身份证号"  prop="idNumber">
                  <el-input readonly =“readonly” v-model="form.idNumber" placeholder="请输入身份证号" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="政治面貌"  prop="politics">
                  <el-select disabled="disabled" v-model="form.politics" placeholder="请选择政治面貌" style="width:90%;float:left">
                    <el-option
                      v-for="dict in dict.type.yh_politics"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
            </el-row>
            <!--第7行-->
            <el-row>
            </el-row>
          </el-main>
        </el-container>

        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">党团员信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="16">
                <el-form-item label="所在支部"  prop="branch">
                  <el-input readonly =“readonly” v-model="form.branch" placeholder="请输入所在支部" style="width:94%;float:left"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="入党/团时间"  prop="partyTime">
                  <el-date-picker clearable
                                  readonly =“readonly”
                                  v-model="form.partyTime"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择入党/团时间"
                                  style="width:94%;float:left">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>

              <el-col :span="16">
                <el-form-item label="家庭住址"  prop="homeAddress">
                  <el-input readonly =“readonly” v-model="form.homeAddress" placeholder="请输入家庭住址" style="width:94%;float:left"/>
                </el-form-item>
              </el-col>


            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">组织关系转接</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="介绍信编号"  prop="note1">
                  <el-input v-model="form.note1" placeholder="请输入介绍信编号" style="width:94%;float:left"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="上级党组织名称"  prop="note2">
                  <el-input v-model="form.note2" placeholder="请输入上级党组织名称" style="width:94%;float:left"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="接收单位名称"  prop="organizationRelationship">
                  <el-input v-model="form.organizationRelationship" placeholder="请输入组织关系接收单位名称" style="width:94%;float:left"/>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="接收单位城市" prop="organizationCity">
                  <el-input v-model="form.organizationCity" placeholder="请输入组织关系接收单位所在城市" style="width:94%;float:left"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>

              <el-col :span="24">
                <el-form-item label="备注"  prop="remark">
                  <el-input v-model="form.remark" type="textarea" placeholder="请输入备注" style="width:97.3%;float:left"/>
                </el-form-item>
              </el-col>
            </el-row>


          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<style>
.el-header, .el-footer {
  background-color: #FFFFFF;
  color: #333;
  text-align: left;
  line-height: 60px;
  font-style: oblique;

}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #FFFFFF;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-dialog__title {
  /*color: #1ab394;*/
  font-weight: bold;
  font-size: 25px;
}
.input_text{
  background-color: #efefef;
  border-color: #efefef;
  border-style:solid;
  border-top-width:0px;
  border-right-width:0px;
  border-bottom-width:1px;
  border-left-width:0px;

  /*border-top-width: 0px;*/
  /*border-left-width: 0px;*/
  /*border-right-width: 0px;*/
  /*border-bottom-width: 1px;*/
}

</style>

<script>
import { listTransfer, getTransfer, delTransfer, addTransfer, updateTransfer } from "@/api/module/dr/transfer";
import {listBaseinfo} from "@/api/module/dr/baseinfo";
import {treeselect} from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {getToken} from "@/utils/auth";
import watermark from "watermark-dom";
export default {
  name: "Transfer",
  components: { Treeselect },
  dicts: ['sys_user_sex',
    'yh_deptid',
    'yh_highest_degree',
    'yh_highest_education',
    'yh_politics',
    'yh_position_grade',
    'yh_technical_position',
    'yh_rank',
    'yh_present_occupation',
    'yh_current_job_level',
    'yh_military_rank',
    'yh_deptid'],
  data() {
    return {
      mounted() {
        watermark.load({ watermark_txt: "  "   });
      },
      options: [{
        value: '1',
        label: '是'
      }, {
        value: '2',
        label: '否'
      }],
      // 基础信息表格数据
      baseInfoList: [],
      option_nation: [
        {value: '汉族', label: '汉族'}, {value: '阿昌族', label: '阿昌族'},
        {value: '鄂温克族', label: '鄂温克族'}, {value: '傈僳族', label: '傈僳族'},
        {value: '水族', label: '水族'}, {value:'白族',label:'白族'},
        {value:'高山族',label:'高山族'}, {value:'珞巴族',label:'珞巴族'},
        {value:'塔吉克族',label:'塔吉克族'}, {value:'保安族',label:'保安族'},
        {value:'仡佬族',label:'仡佬族'}, {value:'满族',label:'满族'},
        {value:'塔塔尔族',label:'塔塔尔族'}, {value:'布朗族',label:'布朗族'},
        {value:'哈尼族',label:'哈尼族'}, {value:'毛南族',label:'毛南族'},
        {value:'土家族',label:'土家族'}, {value:'布依族',label:'布依族'},
        {value:'哈萨克族',label:'哈萨克族'}, {value:'门巴族',label:'门巴族'},
        {value:'土族',label:'土族'}, {value:'朝鲜族',label:'朝鲜族'},
        {value:'蒙古族',label:'蒙古族'}, {value:'佤族',label:'佤族'},
        {value:'达斡尔族',label:'达斡尔族'}, {value:'赫哲族',label:'赫哲族'},
        {value:'苗族',label:'苗族'}, {value:'维吾尔族',label:'维吾尔族'},
        {value:'傣族',label:'傣族'}, {value:'回族',label:'回族'},
        {value:'仫佬族',label:'仫佬族'}, {value:'乌孜别克族',label:'乌孜别克族'},
        {value:'德昂族',label:'德昂族'}, {value:'基诺族',label:'基诺族'},
        {value:'纳西族',label:'纳西族'}, {value:'锡伯族',label:'锡伯族'},
        {value:'东乡族',label:'东乡族'}, {value:'京族',label:'京族'},
        {value:'怒族',label:'怒族'}, {value:'瑶族',label:'瑶族'},
        {value:'侗族',label:'侗族'}, {value:'景颇族',label:'景颇族'},
        {value:'普米族',label:'普米族'}, {value:'彝族',label:'彝族'},
        {value:'独龙族',label:'独龙族'}, {value:'柯尔克孜族',label:'柯尔克孜族'},
        {value:'羌族',label:'羌族'}, {value:'裕固族',label:'裕固族'},
        {value:'俄罗斯族',label:'俄罗斯族'}, {value:'拉祜族',label:'拉祜族'},
        {value:'撒拉族',label:'撒拉族'}, {value:'藏族',label:'藏族'},
        {value:'鄂伦春族',label:'鄂伦春族'}, {value:'黎族',label:'黎族'},
        {value:'畲族',label:'畲族'}, {value:'壮族',label:'壮族'},
        {value:'穿青族',label:'穿青族'}, {value:'达曼族',label:'达曼族'},
      ],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      //部门树选择
      deptOptions: undefined,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 关系转接表格数据
      transferList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        username: null,
        departmentTitle: null,
        birth: null,
        gender: null,
        certificateId: null,
        age: null,
        deptid:null,
        idNumber: null,
        phoneOne: null,
        phoneSecond: null,
        nativePlace: null,
        birthplace: null,
        nation: null,
        highestEducation: null,
        highestDegree: null,
        graduationSchool: null,
        major: null,
        personnelCategory: null,
        politics: null,
        workingTime: null,
        militaryTime: null,
        educationTraining: null,
        combatParticipation: null,
        majorOperations: null,
        reward: null,
        resume: null,
        baseRank: null,
        userId: null,
        deptId: null,
        branchId: null,
        branch: null,
        branchStatus: null,
        homeAddress: null,
        formalPreparation: null,
        entryTime: null,
        partyTime: null,
        turnPositive: null,
        isPositive: null,
        organizationRelationship: null,
        organizationCity: null,
        reviewerId: null,
        reviewerStatus: null,
        reviewerResult: null,
        reviewerTiem: null,
        reviewerComments: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },
      // 列信息
      columns: [
        {key: 0, label: `姓名`, visible: true},
        {key: 1, label: `性别`, visible: false},
        {key: 2, label: `年龄`, visible: false},
        {key: 3, label: `部门`, visible: true},
        {key: 4, label: `身份证号`, visible: false},
        {key: 5, label: `籍贯`, visible: false},
        {key: 6, label: `民族`, visible: false},
        {key: 7, label: `政治面貌`, visible: true},
        {key: 8, label: `所在支部`, visible: true},
        {key: 9, label: `家庭住址`, visible: false},
        {key: 10, label: `介绍信编号`, visible: true},
        {key: 11, label: `上级党组织名称`, visible: false},
        {key: 12, label: `入党/团时间`, visible: false},
        {key: 13, label: `组织关系接收单位名称`, visible: false},
        {key: 14, label: `组织关系接收单位所在城市`, visible: false},
        {key: 15, label: `备注`, visible: false}
      ],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        username: [
          {
            required: true, message: "姓名不能为空", trigger: "blur" },
        ],
        idNumber: [
          { required: true, message: "身份证号不能为空", trigger: "blur" },
        ],
        deptid: [
          { required: true, message: "部门不能为空", trigger: "blur" },
        ]
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/dr/transfer/importData"
      }
    };
  },
  created() {
    this.getList();
    this.getBaseInfo();
    this.getTreeselect();
  },
  methods: {
    //下拉列表获取所有用户基本信息
    getBaseInfo() {
      listBaseinfo().then(response => {
        this.baseInfoList = response.rows;
        console.log('baseInfoList '+this.baseInfoList)
      });
    },
    getTreeselect(){
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    /** 查询关系转接列表 */
    getList() {
      this.loading = true;
      listTransfer(this.queryParams).then(response => {
        this.transferList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        username: null,
        departmentTitle: null,
        birth: null,
        gender: null,
        certificateId: null,
        age: null,
        deptid:null,
        idNumber: null,
        phoneOne: null,
        phoneSecond: null,
        nativePlace: null,
        birthplace: null,
        nation: null,
        highestEducation: null,
        highestDegree: null,
        graduationSchool: null,
        major: null,
        personnelCategory: null,
        politics: null,
        workingTime: null,
        militaryTime: null,
        educationTraining: null,
        combatParticipation: null,
        majorOperations: null,
        reward: null,
        resume: null,
        baseRank: null,
        userId: null,
        deptId: null,
        branchId: null,
        branch: null,
        branchStatus: null,
        homeAddress: null,
        formalPreparation: null,
        entryTime: null,
        partyTime: null,
        turnPositive: null,
        isPositive: null,
        organizationRelationship: null,
        organizationCity: null,
        reviewerId: null,
        reviewerStatus: null,
        reviewerResult: null,
        reviewerTiem: null,
        reviewerComments: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.usernames = selection.map(item => item.username)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加党关系转接";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTransfer(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改党关系转接";
      });
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('/dr/transfer/importTemplate', {}, `user_template_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "党团员导入";
      this.upload.open = true;
    },    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTransfer(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTransfer(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 详细按钮操作 */
    handleView(row) {
      const id = row.id;
      this.$router.push({ path:"/jiben/drtransferdetail", query: {id}});
      console.log(id);
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      const usernames = row.username || this.usernames;
      this.$modal.confirm('是否确认删除姓名为"' + usernames + '"的数据项？').then(function() {
        return delTransfer(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('dr/transfer/export', {
        ...this.queryParams
      }, `transfer_${new Date().getTime()}.xlsx`)
    },
    //queryString 为在框中输入的值
    //cb 回调函数，将处理好的数据推回
    querySearchAsync(queryString, cb) {
      //因为autocomplete只识别value字段,所以用replace(/需要用的字段/g,"value")，将需要用的字段全部替换成value
      //(/***/g 是全部替换，如果不用全部替换，可以参考https://www.w3school.com.cn/jsref/jsref_replace.asp)
      let baseInfoJson= JSON.parse(JSON.stringify(this.baseInfoList).replace(/username/g,"value"));
      console.log('baseInfoJson '+baseInfoJson)
      let results = queryString ? baseInfoJson.filter(this.createStateFilter(queryString)) : baseInfoJson;
      console.log('results '+results)
      clearTimeout(this.timeout);
      this.timeout = setTimeout(() => {
        cb(results);
      }, 0.5*1000);
    },
    //根据输入的字段进行筛选
    createStateFilter(queryString) {
      return (state) => {
        return (state.value.toString().toLowerCase().indexOf(queryString.toLowerCase()) === 0);
      };
    },

    //将其他数据自动补全，采用覆盖的方法
    handleSelect(item){
      this.form.username = item.value;
      this.form.idNumber=item.idNumber;
      this.form.certificateId=item.certificateId;
      this.form.deptid = item.deptId;
      this.form.age = item.age;
      this.form.nativePlace = item.nativePlace;
      this.form.nation = item.nation;
      this.form.gender = item.gender;
      this.form.politics = item.politics;
    },
  }
};
</script>
